﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Assignment3.Objects3D
{
    class Enemy
    {
        public Vector3 position, scale;      

        public Enemy(Vector3 position, Vector3 scale)
        {
            this.position = position;
            this.scale = scale;
        }

        public void DrawModel(Model model, BasicEffect basicEffect, float rotateX, float rotateY, float rotateZ)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.PreferPerPixelLighting = true;

                    //enable fog for the model
                    effect.FogColor = basicEffect.FogColor;
                    effect.FogEnd = basicEffect.FogEnd;
                    effect.FogStart = basicEffect.FogStart;
                    effect.FogEnabled = basicEffect.FogEnabled;

                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale) * Matrix.CreateTranslation(position) * basicEffect.World * Matrix.CreateRotationX(MathHelper.ToRadians(rotateX)) * Matrix.CreateRotationY(MathHelper.ToRadians(rotateY)) * Matrix.CreateRotationZ(MathHelper.ToRadians(rotateZ));
                    effect.View = basicEffect.View;
                    effect.Projection = basicEffect.Projection;
                }
                mesh.Draw();
            }
        }
    }
}
